<template>
	<view>
		<view view class="inv-h-w">
			<view class="inv-card" @click="inv_se = 1">
				<view :class="['title',inv_se==1?'selected-title':'']">
					<text v-if="inv_se==1">
						<text class="iconfont">&#xe601;</text>未审核申请列表
					</text>
					<text class="iconfont" v-else>&#xe601;</text>
				</view>
			</view>
			<view class="inv-card" @click="inv_se = 2">
				<view :class="['title',inv_se==2?'selected-title':'']">
					<text v-if="inv_se==2">
						<text class="iconfont">&#xe612;</text>已审核申请列表
					</text>
					<text class="iconfont" v-else>&#xe612;</text>
				</view>
			</view>
		</view>
		<view v-show="inv_se == 1">
			<view class="no-content" v-if=" unAuditList==null||unAuditList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in unAuditList" :key="index">
				<uni-collapse class="warp">
					<uni-collapse-item :show-animation="true" :title="'学号:'+item.apply.sid + '  姓名:' + item.student.name">
						<text class="content" v-if="item.apply.baid!==null && item.apply.baid!==''">
							<text class="iconfont" style="color: #e64340;">&#xe7cb;</text>申请编号：{{item.apply.baid}}
						</text>
						<text class="content" v-if="item.apply.sid!==null && item.apply.sid!==''">
							<text class="iconfont" style="color: #e609b6;">&#xe62f;</text>申请人id：{{item.apply.sid}}
						</text>
						<text class="content" v-if="item.apply.bid!==null && item.apply.bid!==''">
							<text class="iconfont" style="color: #67e612;">&#xe611;</text>归国信息编号：{{item.apply.bid}}
						</text>
						<text class="content" v-if="item.apply.con !==null && item.apply.con!==''">
							<text class="iconfont" style="color: #0f0fe6;">&#xe807;</text>简述：{{item.apply.con}}
						</text>
						<text class="content" v-if="item.time!==null && item.apply.time!==''">
							<text class="iconfont" style="color: #05dbe6;">&#xe62a;</text>申请时间：{{item.apply.time}}
						</text>
						<view class="content operaton">
							<button type="primary" size="mini" @click="go(item.apply.bid)"><text class="iconfont" style="font-size: 10px;">&#xe6d1;</text>详情</button>
							<button type="primary" size="mini" @click="pass(item.apply.baid,item.apply.sid,item.apply.bid,item.apply.con,item.apply.time)"><text class="iconfont" style="font-size: 10px;">&#xe612;</text>通过</button>
							<button type="primary" size="mini" @click="unpass(item.apply.baid,item.apply.sid,item.apply.bid,item.apply.con,item.apply.time)"><text class="iconfont" style="font-size: 10px;">&#xe606;</text>否决</button>
						</view>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
		<view v-show="inv_se == 2">
			<view class="no-content" v-if="passedAuditList==null||passedAuditList.length===0">
				<text>已将到底了</text>
			</view>
			<view v-for="(item, index) in passedAuditList" :key="index">
				<uni-collapse class="warp">
					<view class="show" >
						<image v-if="item.apply.past == 0" src="../../../static/image/result/unpass.png"></image>
						<image v-else src="../../../static/image/result/pass.png"></image>
					</view>
					<uni-collapse-item :show-animation="true" :title="'学号:'+item.apply.sid + '  姓名:' + item.student.name" >
						<text class="content" v-if="item.apply.baid!==null && item.apply.baid!==''">
							<text class="iconfont" style="color: #e64340;">&#xe7cb;</text>申请编号：{{item.apply.baid}}
						</text>
						<text class="content" v-if="item.apply.sid!==null && item.apply.sid!==''">
							<text class="iconfont" style="color: #e609b6;">&#xe62f;</text>申请人id：{{item.apply.sid}}
						</text>
						<text class="content" v-if="item.apply.bid!==null && item.apply.bid!==''">
							<text class="iconfont" style="color: #67e612;">&#xe611;</text>归国信息编号：{{item.apply.bid}}
						</text>
						<text class="content" v-if="item.apply.con !==null && item.apply.con!==''">
							<text class="iconfont" style="color: #0f0fe6;">&#xe807;</text>简述：{{item.apply.con}}
						</text>
						<text class="content" v-if="item.apply.time!==null && item.apply.time!==''">
							<text class="iconfont" style="color: #05dbe6;">&#xe62a;</text>申请时间：{{item.apply.time}}
						</text>
						<text class="content" v-if="item.apply.past !==null && item.apply.past!==''">
							<text class="iconfont" style="color: #e6c91f;">&#xe76d;</text>审核结果：
							<text class="iconfont r1" v-if="item.apply.past==1">&#xe61b;</text>
							<text class="iconfont r2" v-else>&#xe625;</text>
						</text>
						<view class="content operaton">
							<button type="primary" size="mini" @click="go(item.apply.bid)"><text class="iconfont" style="font-size: 10px;">&#xe6d1;</text>详情</button>
							<button type="primary" size="mini" @click="regret(item.apply.baid,item.apply.sid,item.apply.bid,item.apply.con,item.apply.time)"><text class="iconfont" style="font-size: 10px;">&#xe60e;</text>取消</button>
						</view>
					</uni-collapse-item>
				</uni-collapse>
			</view>
		</view>
	</view>
</template>

<script>
	import * as abroadRequest from '@/api/tAbroad.js'

	import {
		uniCollapse,
		uniCollapseItem
	} from '@dcloudio/uni-ui'

	export default {
		components: {
			uniCollapse,
			uniCollapseItem
		},
		data() {
			return {
				inv_se: 1,
				unAuditList: [],
				passedAuditList: []
			}
		},
		methods: {
			getData() {
				uni.showLoading()
				abroadRequest.changeList({
					tid: getApp().globalData.tid,
					apply: 0
				}).then(res => {
					this.unAuditList = res.data.data
				})
				abroadRequest.changeList({
					tid: getApp().globalData.tid,
					apply: 1
				}).then(res => {
					uni.hideLoading()
					this.passedAuditList = res.data.data
				})
			},
			pass(baid, sid, bid, con, time) {
				uni.showModal({
					content: '您确定通过？',
					success: (res) => {
						if (res.confirm) {
							abroadRequest.changeApply({
								baid: baid,
								tid: getApp().globalData.tid,
								sid: sid,
								bid: bid,
								con: con,
								time: time,
								apply: 1,
								past: 1
							}).then(res => {
								if (res.data.code == 0) {
									uni.showModal({
										content: '操作成功',
										showCancel: false,
										success: () => {
											this.getData()
										}
									})
								}
							})
						}
					}
				})
			},
			unpass(baid, sid, bid, con, time) {
				uni.showModal({
					content: '您确定不通过？',
					success: (res) => {
						if (res.confirm) {
							abroadRequest.changeApply({
								baid: baid,
								tid: getApp().globalData.tid,
								sid: sid,
								bid: bid,
								con: con,
								time: time,
								apply: 1,
								past: 0
							}).then(res => {
								if (res.data.code == 0) {
									uni.showModal({
										content: '操作成功',
										showCancel: false,
										success: () => {
											this.getData()
										}
									})
								}
							})
						}
					}
				})
			},
			regret(baid, sid, bid, con, time) {
				uni.showModal({
					content: '您确定取消审核？',
					success: (res) => {
						if (res.confirm) {
							abroadRequest.changeApply({
								baid: baid,
								tid: getApp().globalData.tid,
								sid: sid,
								bid: bid,
								con: con,
								time: time,
								apply: 0,
								past: 0
							}).then(res => {
								if (res.data.code == 0) {
									uni.showModal({
										content: '操作成功',
										showCancel: false,
										success: () => {
											this.getData()
										}
									})
								}
							})
						}
					}
				})
			},
			go(bid){
				uni.navigateTo({
					url:'./changeDetail?bid='+bid
				})
			}
		},
		onLoad() {
			this.getData()
		}
	}
</script>

<style>
	page{
		font-family: 'Courier New', Courier, monospace;
	}
	.iconfont {
		font-family: "iconfont" !important;
		font-size: 20px;
		font-style: normal;
		-webkit-font-smoothing: antialiased;
		-moz-osx-font-smoothing: grayscale;
	}

	.inv-h-w {
		height: 50px;
		background-color: #ffffff;
		border-bottom: 1px solid #F7F7F7;
	}

	.inv-card {
		height: 100%;
		line-height: 50px;
		display: inline-block;
		position: relative;
	}

	.inv-card .title {
		color: #FFFFFF;
		height: 50px;
		font-size: 18px;
		box-sizing: border-box;
		background-color: #ffaa00c2;
		padding-right: 40px;
		padding-left: 10px;
	}

	.inv-card .selected-title {
		background-color: #ffaa00;
	}

	.inv-card ::after {
		content: "";
		position: absolute;
		right: 0;
		top: 0;
		border-right: 50px solid white;
		border-left: 50px solid transparent;
		border-bottom: 50px solid transparent;
	}

	.no-content {
		display: flex;
		height: auto;
		padding: 10px;
		font-size: 14px;
		justify-content: center;
		align-items: center;
		background-color: #f7f7f7;
	}

	.content {
		padding: 15px;
		font-size: 18px;
		line-height: 20px;
		background-color: #fbfbfb;
		color: #666;
		border-bottom: 1px dotted #c8c7cc;
		margin: 0 5px 10px 5px ;
		box-shadow: 5px 5px 3px #d3cfb0;
		border-radius: 5px;
	}

	.operaton {
		text-align: center;
	}

	.operaton button {
		margin: 0 10px;
	}
	
	.r1 {
		font-size: 50px;
		color: #4CD964;
	}
	.r2{
		font-size: 50px;
		color: #e64340;
	}
	
	uni-collapse, uni-collapse-item{
		position: relative;
		z-index: auto;
	}
	
	.show{
		position: absolute;
		width: 40px;
		height: 40px;
		right:50px;
		z-index:10;
	}
	
	.show image{
		width: 50px;
		height: 50px;
	}
</style>
